<template>
  <div class="favorites">
    <h2>Your Favorites</h2>
    <ul>
      <li v-for="favorite in favorites" :key="favorite">{{ favorite }}</li>
    </ul>
  </div>
</template>

<script>
import axios from 'axios';

export default {
  data() {
    return {
      favorites: []
    };
  },
  mounted() {
    this.fetchFavorites();
  },
  methods: {
    async fetchFavorites() {
      try {
        const response = await axios.get('/backend/api/account/favorites/', {
        withCredentials: true // 启用跨域请求时发送 Cookie
      });
        this.favorites = response.data.favorites;
      } catch (error) {
        console.error('Failed to fetch favorites:', error);
      }
    }
  }
};
</script>

<style scoped>
.favorites {
  padding: 20px;
  background-color: #fff;
  border-radius: 10px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

h2{
  color:black;
}
</style>